package ink.tiptop.controller;

import ink.tiptop.dto.req.remote.publish.PublishRequest;
import ink.tiptop.dto.req.remote.publish.QueryPublishRequest;
import ink.tiptop.common.domain.rsp.Response;
import ink.tiptop.service.PublishService;
import ink.tiptop.utils.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author ink.tiptop.zjf
 * @Title: Ticket
 * @Package ink.tiptop.controller.remote
 * @Description:   发布维度的controller
 * @date 2020-07-30 21:32
 */
@Api("发布服务模块API")
@RestController
@RequestMapping("publishController")
@Slf4j
public class PublishController {

    /**
     * 服务对象
     */
    @Resource
    private PublishService publishService;

    /**
     * 列表展示本地模块
     */
    @ApiOperation("列出可以发布的jar列表")
    @PostMapping("list")
    @ResponseBody
    public Response list(@RequestBody @Valid QueryPublishRequest request) {
        log.info("列出可以发布的jar列表,入参:{}", JSON.toJSONString(request));
        return this.publishService.list(request);
    }
    /**
     * 发布本地模块到远程服务器
     */
    @ApiOperation("选择发布的模块")
    @PostMapping("publish")
    @ResponseBody
    public Response publish(@RequestBody @Valid PublishRequest request) {
        log.info("选择发布的模块,入参:{}", JSON.toJSONString(request));
        return this.publishService.publish(request);
    }

}
